home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / SPRITES1.ASM < prev    next >
Assembly Source File  |  1986-05-27  |  23KB  |  541 lines

  1. ;
  2. ; *** Listing 1 ***
  3. ;
  4. ;This program demonstrates the use of a set of routines which
  5. ; allow smooth, non-flickering, and non-destructive animation
  6. ; of objects on an IBM CGA or EGA graphics adapter. The program
  7. ; moves two helicopters and a balloon along programmed paths while
  8. ; internally animating the helicopter's roters, and orientation. You
  9. ; will see no undesirable fringe or overlap effects. Objects look
  10. ; as if they are in separate planes, and blank areas within an object
  11. ; such as the windows of the helicopters appear to be transparent.
  12. ;
  13. ; Link with Listings 2 and 3 with the command:
  14. ;    link sprites1+sprites2+sprites3;
  15. ; to generate the executable sprite application file sprites1.exe.
  16. ;
  17. stack    segment para stack 'STACK'
  18.     db    100 dup('Stack')
  19. stack    ends
  20. ;
  21. ;Segment used to hold memory image of the background. It is used to
  22. ; restore the background before an object is moved.
  23. ;
  24. background_segment  segment para 'DATA'
  25.     db    4000h-((4000h-16000)/2) dup(0) ;last 192 bytes of the
  26. background_segment  ends               ; 16K video memory
  27. ;                           ; buffer are never used
  28. cseg    segment para public 'cseg'
  29.     assume    cs:cseg,ds:cseg,es:nothing
  30.     extrn    byte_move_form_driver:near
  31.     extrn    initialize:near,terminate:near,object_services:near
  32.     extrn    vert_int_modulo_count:word
  33.     extrn    put_objects_on_screen:far
  34. ;
  35. ;The flag below must be set properly before assembling this program
  36. ;
  37. ega    equ  0 ;1 to assemble for use on an Enhanced Graphics Adapter
  38.            ;0 to assemble for use on a Color Graphics Adapter
  39. cga    equ  (ega xor 1) ;the opposite status of ega
  40. ;
  41. if ega
  42. old_vert_count    dw    0    ;holds number used to synchronize this
  43.                 ; program to vertical interrupt
  44. endif
  45. ;
  46. screen_buffer_adr    equ    0b800h        ;video mode 4's buffer
  47.                         ; paragraph address
  48. ;
  49. num_objects    equ    3    ;this program will move three objects
  50. ;
  51. ;Below is a table which holds all the parameters which govern the
  52. ; movement of the three individual objects
  53. x        dw             15,           38,          64
  54. y        dw             90,          180,         164
  55. xinc        dw              1,        0,          -1
  56. yinc        dw              0,           -2,           0
  57. form        dw       bcptr_rt_tbl,      balloon_tbl,     rcptr_lft_tbl
  58. formbase    dw       bcptr_rt_tbl,      balloon_tbl,     rcptr_lft_tbl
  59. formmax     dw bcptr_rt_tbl_max,  balloon_tbl_max, rcptr_lft_tbl_max
  60. control     dw      copter1_cinit,    balloon_cinit,     copter0_cinit
  61. controlbase dw    copter1_control,  balloon_control,   copter0_control
  62. controlmax  dw copter1_cntl_max, balloon_cntl_max,  copter0_cntl_max
  63. delay        dw             01,           01,          01
  64. delaybase   dw             04,           12,          06
  65. repeat        dw             47,           91,          55
  66. ;
  67. ;Below are lists of parameters which control the sequence of
  68. ; parameters used to define the movement patterns, and shapes.
  69. ; The parameters are listed in the following order:
  70. ;    xinc, yinc, form, formmax, delay, repeat
  71. ;
  72.  
  73. copter0_control dw -1,0
  74.         dw rcptr_lft_tbl,rcptr_lft_tbl_max,06,54
  75. copter0_cinit    dw 0,-2
  76.         dw rcptr_lft_tbl,rcptr_lft_tbl_max,06,35
  77.         dw 1,0
  78.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,06,4
  79.         dw 1,2
  80.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,08,10
  81.         dw 1,-2
  82.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,08,8
  83.         dw 1,-2
  84.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,08,4
  85.         dw 0,0
  86.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,10,10
  87.         dw 1,-2
  88.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,08,4
  89.         dw 1,-2
  90.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,08,9
  91.         dw 1,2
  92.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,08,15
  93.         dw 0,2
  94.         dw rcptr_rt_tbl,rcptr_rt_tbl_max,10,35
  95. copter0_cntl_max label     byte
  96. ;
  97. copter1_control dw 1,0
  98.         dw bcptr_rt_tbl,bcptr_rt_tbl_max,04,46
  99. copter1_cinit    dw -1,0
  100.         dw bcptr_lft_tbl,bcptr_lft_tbl_max,04,46
  101.         dw 1,0
  102.         dw bcptr_rt_tbl,bcptr_rt_tbl_max,04,46
  103.         dw -1,0
  104.         dw bcptr_lft_tbl,bcptr_lft_tbl_max,04,46
  105.         dw 0,0
  106.         dw disappear_table,disappear_table_max,300,1
  107. copter1_cntl_max label     byte
  108. ;
  109. balloon_control dw    0,-2
  110.         dw    balloon_tbl,balloon_tbl_max,12,70
  111. balloon_cinit    dw    0,2
  112.         dw    balloon_tbl,balloon_tbl_max,12,70
  113. balloon_cntl_max     label   byte
  114. ;
  115. ;Below are tables used to sequence the internal animation
  116. ;
  117. rcptr_lft_tbl       label   word
  118.     dw    rcopter_left0
  119.     dw    rcopter_left1
  120. rcptr_lft_tbl_max  label   word
  121. ;
  122. rcptr_rt_tbl     label     word
  123.     dw    rcopter_right0
  124.     dw    rcopter_right1
  125. rcptr_rt_tbl_max label     word
  126. ;
  127. bcptr_lft_tbl       label   word
  128.     dw    bcopter_left0
  129.     dw    bcopter_left1
  130. bcptr_lft_tbl_max  label   word
  131. ;
  132. bcptr_rt_tbl     label     word
  133.     dw    bcopter_right0
  134.     dw    bcopter_right1
  135. bcptr_rt_tbl_max label     word
  136. ;
  137. balloon_tbl          label   word
  138.     dw    balloon
  139. balloon_tbl_max       label   word
  140. ;
  141. disappear_table       label   word
  142.     dw    0ffffh
  143. disappear_table_max      label   word
  144. ;
  145. ;Below are the forms used to define the various images of the objects
  146. ; in a form suitable for an AND-OR type form driver. The format is:
  147. ;    byte 0 - height in lines (h)
  148. ;    byte 1 - width in bytes  (w)
  149. ;    followed by w X h (mask word, image word) pairs.
  150. ;
  151. rcopter_left0    label    byte
  152.     DB  00Eh, 006h, 000h, 000h, 0FFh, 0FFh, 000h, 00Fh, 0FFh, 0F0h
  153.     DB  0FFh, 0FFh, 000h, 000h, 0FFh, 0F0h, 000h, 00Fh, 000h, 00Fh
  154.     DB  0FFh, 0F0h, 0FFh, 0FFh, 000h, 000h, 0FFh, 0F0h, 000h, 00Fh
  155.     DB  0FFh, 0FFh, 000h, 000h, 0FFh, 0FFh, 000h, 000h, 0FCh, 000h
  156.     DB  002h, 0AAh, 003h, 0FFh, 0A8h, 000h, 0FFh, 0FFh, 000h, 000h
  157.     DB  0F3h, 0FFh, 008h, 000h, 0C0h, 0FFh, 02Ah, 000h, 0FFh, 03Fh
  158.     DB  000h, 0C0h, 0CFh, 0FFh, 020h, 000h, 0F0h, 03Fh, 00Ah, 080h
  159.     DB  0FFh, 03Fh, 000h, 0C0h, 03Fh, 0FFh, 080h, 000h, 0F0h, 00Ch
  160.     DB  00Ah, 0A2h, 03Fh, 03Fh, 080h, 0C0h, 03Fh, 0FFh, 080h, 000h
  161.     DB  0F0h, 003h, 00Ah, 0A8h, 0C0h, 000h, 03Fh, 0FFh, 03Fh, 0FFh
  162.     DB  080h, 000h, 0C0h, 00Ch, 02Ah, 0A2h, 03Fh, 03Fh, 080h, 0C0h
  163.     DB  000h, 000h, 0AAh, 0AAh, 000h, 03Fh, 0AAh, 080h, 0FFh, 03Fh
  164.     DB  000h, 0C0h, 0C0h, 000h, 02Ah, 0AAh, 000h, 0FFh, 0AAh, 000h
  165.     DB  0FFh, 03Fh, 000h, 0C0h, 0F0h, 000h, 00Ah, 0AAh, 003h, 0FFh
  166.     DB  0A8h, 000h, 0FFh, 0FFh, 000h, 000h, 03Ch, 0FFh, 0C3h, 000h
  167.     DB  0CFh, 03Fh, 030h, 0C0h, 0FFh, 0FFh, 000h, 000h, 0C0h, 000h
  168.     DB  03Fh, 0FFh, 000h, 0FFh, 0FFh, 000h, 0FFh, 0FFh, 000h, 000h
  169. rcopter_left1    label    byte
  170.     DB  00Eh, 006h, 000h, 000h, 0FFh, 0FFh, 000h, 00Fh, 0FFh, 0F0h
  171.     DB  0FFh, 0FFh, 000h, 000h, 000h, 000h, 0FFh, 0FFh, 0FFh, 0FFh
  172.     DB  000h, 000h, 0FFh, 0FFh, 000h, 000h, 0FFh, 0F0h, 000h, 00Fh
  173.     DB  0FFh, 0FFh, 000h, 000h, 0FFh, 0FFh, 000h, 000h, 0FCh, 000h
  174.     DB  002h, 0AAh, 003h, 0FFh, 0A8h, 000h, 0FFh, 0FFh, 000h, 000h
  175.     DB  0F3h, 0FFh, 008h, 000h, 0C0h, 0FFh, 02Ah, 000h, 0FFh, 0FFh
  176.     DB  000h, 000h, 0CFh, 0FFh, 020h, 000h, 0F0h, 03Fh, 00Ah, 080h
  177.     DB  0F3h, 0F3h, 00Ch, 00Ch, 03Fh, 0FFh, 080h, 000h, 0F0h, 00Ch
  178.     DB  00Ah, 0A2h, 03Ch, 0CFh, 083h, 030h, 03Fh, 0FFh, 080h, 000h
  179.     DB  0F0h, 003h, 00Ah, 0A8h, 0C0h, 03Fh, 02Ah, 0C0h, 03Fh, 0FFh
  180.     DB  080h, 000h, 0C0h, 00Ch, 02Ah, 0A2h, 03Ch, 0CFh, 083h, 030h
  181.     DB  000h, 000h, 0AAh, 0AAh, 000h, 03Fh, 0AAh, 080h, 0F3h, 0F3h
  182.     DB  00Ch, 00Ch, 0C0h, 000h, 02Ah, 0AAh, 000h, 0FFh, 0AAh, 000h
  183.     DB  0FFh, 0FFh, 000h, 000h, 0F0h, 000h, 00Ah, 0AAh, 003h, 0FFh
  184.     DB  0A8h, 000h, 0FFh, 0FFh, 000h, 000h, 03Ch, 0FFh, 0C3h, 000h
  185.     DB  0CFh, 03Fh, 030h, 0C0h, 0FFh, 0FFh, 000h, 000h, 0C0h, 000h
  186.     DB  03Fh, 0FFh, 000h, 0FFh, 0FFh, 000h, 0FFh, 0FFh, 000h, 000h
  187. rcopter_right0    label    byte
  188.     DB  00Eh, 006h, 0FFh, 0FFh, 000h, 000h, 0F0h, 000h, 00Fh, 0FFh
  189.     DB  000h, 000h, 0FFh, 0FFh, 0FFh, 0FFh, 000h, 000h, 0FFh, 0FFh
  190.     DB  000h, 000h, 000h, 000h, 0FFh, 0FFh, 0FFh, 0FFh, 000h, 000h
  191.     DB  0FFh, 0FFh, 000h, 000h, 00Fh, 0FFh, 0F0h, 000h, 0FFh, 0FFh
  192.     DB  000h, 000h, 0FFh, 0C0h, 000h, 02Ah, 000h, 03Fh, 0AAh, 080h
  193.     DB  0FCh, 0FFh, 003h, 000h, 0FFh, 003h, 000h, 0A8h, 0FFh, 0CFh
  194.     DB  000h, 020h, 0FCh, 0FFh, 003h, 000h, 0FCh, 00Fh, 002h, 0A0h
  195.     DB  0FFh, 0F3h, 000h, 008h, 0FCh, 0FCh, 003h, 002h, 030h, 00Fh
  196.     DB  08Ah, 0A0h, 0FFh, 0FCh, 000h, 002h, 000h, 003h, 0FFh, 0FCh
  197.     DB  0C0h, 00Fh, 02Ah, 0A0h, 0FFh, 0FCh, 000h, 002h, 0FCh, 0FCh
  198.     DB  003h, 002h, 030h, 003h, 08Ah, 0A8h, 0FFh, 0FCh, 000h, 002h
  199.     DB  0FCh, 0FFh, 003h, 000h, 0FCh, 000h, 002h, 0AAh, 000h, 000h
  200.     DB  0AAh, 0AAh, 0FCh, 0FFh, 003h, 000h, 0FFh, 000h, 000h, 0AAh
  201.     DB  000h, 003h, 0AAh, 0A8h, 0FFh, 0FFh, 000h, 000h, 0FFh, 0C0h
  202.     DB  000h, 02Ah, 000h, 00Fh, 0AAh, 0A0h, 0FFh, 0FFh, 000h, 000h
  203.     DB  0FCh